<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf"><?= $title ?></div>
                </div>
				<div class="widget-body am-fr">
                    <!-- 工具栏 -->
                    <div class="page_toolbar am-margin-bottom-xs am-fr">
                        <form class="toolbar-form" action="<?= url('order/export_order')?>" method="POST">
                            <div class="am-u-sm-12">
                                <div class="am fr">
                                    <div class="am-form-group tpl-form-border-form am-fl">
                                        <input type="text" name="time[star]"
                                               class="am-form-field"
                                               value="" placeholder="请选择起始日期"
                                               data-am-datepicker required>
                                    </div>
                                    <div class="am-form-group tpl-form-border-form am-fl">
                                        <input type="text" name="time[end]"
                                               class="am-form-field"
                                               value="" placeholder="请选择截止日期"
                                               data-am-datepicker required>
                                    </div>
									<div class="am-form-group am-fl">
										<div class="am-btn-toolbar">
											<div class="am-btn-group am-btn-group-xs">
												<button class="am-btn am-btn-secondary am-radius" type="submit">
													<span class="am-icon-download"></span> 订单导出
												</button>
											</div>
										</div>
									</div>
                                </div>
                            </div>
                        </form>
                        <form class="toolbar-form" action="">
                            <input type="hidden" name="s" value="/store/order/all_list">
                            <div class="am-u-sm-12">
                                <div class="am fr">
                                    <div class="am-form-group am-fl">
                                        <div class="am-input-group am-input-group-sm tpl-form-border-form">
                                            <input type="text" class="am-form-field" name="search"
                                                   placeholder="请输入订单号"
                                                   value="">
                                            <div class="am-input-group-btn">
                                                <button class="am-btn am-btn-default am-icon-search"
                                                        type="submit"></button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="order-list am-scrollable-horizontal am-u-sm-12 am-margin-top-xs">
                        <table width="100%" class="am-table am-table-centered
                        am-text-nowrap am-margin-bottom-xs">
                            <thead>
                            <tr>
                                <th class="goods-detail">商品信息</th>
                                <th width="100px">单价/数量</th>
                                <th>实付款</th>
                                <th>买家</th>
                                <th>交易状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if (!$list->isEmpty()): foreach ($list as $order): ?>
                                <tr class="order-empty">
                                    <td colspan="6"></td>
                                </tr>
                                <tr>
                                    <td class="am-text-middle am-text-left" colspan="6">
                                        <?php if($app_type == 'food'):?>
										<span class="am-margin-right-lg">
											<?= ($order['order_mode']['value']==10 AND $order['row_no'] <> '')?'# 堂食：'.$order['row_no'].'号 #':'' ?>
											<?= $order['order_mode']['value']==30?'# 自取：'.$order['row_no'].'号 到店时间：'.$order['arrive_time']['text'].'#' : '' ?>
											<?= $order['order_mode']['value']==20?'# 外卖：'.$order['row_no'].'号 #':'' ?>
											<?= ($order['order_mode']['value']==10 AND $order['row_no'] == '')?'# 餐桌/包间：'.$order['table']['table_name'].' - '.$order['people'].'人就餐 #':'' ?>
										</span>
                                        <?php endif;?>
										<span class="am-margin-right-lg">门店：<?= $order['shop']['shop_name'] ?></span>
                                        <span class="am-margin-right-lg">来源：<?= $order['source']['text'] ?></span>
                                        <span class="am-margin-right-lg">订单号：<?= $order['order_no'] ?></span>
                                        <span class="am-margin-right-lg"> <?= $order['create_time'] ?></span>
                                    </td>
                                </tr>
                                <?php $i = 0;
                                foreach ($order['goods'] as $goods): $i++; ?>
                                    <tr>
                                        <td class="goods-detail am-text-middle">
                                            <div class="goods-image">
                                                <img src="<?= $goods['image'] == null ? $goods['thumbnail'] : $goods['image']['file_path'] ?>" alt="">
                                            </div>
                                            <div class="goods-info">
                                                <p class="goods-title"><?= $goods['goods_name'] ?></p>
                                                <p class="goods-spec am-link-muted">
                                                    <?= $goods['goods_attr'] ?>
                                                </p>
                                            </div>
                                        </td>
                                        <td class="am-text-middle">
                                            <p>￥<?= $goods['goods_price'] ?> × <?= $goods['total_num'] ?></p>
											<?php if($order['order_status']['value']==40):?>
                                            <p>退 × <?= $goods['refund_num'] ?></p>
											<?php endif;?>
                                        </td>
                                        <?php if ($i === 1) : $goodsCount = count($order['goods']); ?>
                                            <td class="am-text-middle" rowspan="<?= $goodsCount ?>">
                                                <p>￥<?= $order['pay_price'] ?></p>
                                                <p class="am-link-muted">(优惠额：-￥<?= $order['activity_price'] ?>)</p>
												<?php if($order['pack_price']>0):?>
													<p class="am-link-muted">(包装费：+￥<?= $order['pack_price'] ?>)</p>
												<?php endif;?>
												<?php if($order['express_price']>0):?>
													<p class="am-link-muted">(配送费：+￥<?= $order['express_price'] ?>)</p>
												<?php endif;?>
                                                <?php if($order['ware_price']>0):?>
													<p class="am-link-muted">(餐具费：+￥<?= $order['ware_price'] ?>)</p>
												<?php endif;?>
												<?php if($order['order_status']['value']==40):?>
													<p>退款：-￥<?= $order['refund_price'] ?></p>
												<?php endif;?>
                                            </td>
                                            <td class="am-text-middle" rowspan="<?= $goodsCount ?>">
                                                <p><?= $order['user']['nickName'] ?></p>
                                                <p class="am-link-muted">(用户id：<?= $order['source']['value']==10?$order['user']['user_id']:$order['user']['store_user_id']?>)</p>
                                            </td>
                                            <td class="am-text-middle" rowspan="<?= $goodsCount ?>">
                                                <p>付款状态：
                                                    <span class="am-badge
                                                <?= $order['pay_status']['value'] == 20 ? 'am-badge-success' : '' ?>
                                                <?= $order['pay_status']['value'] == 30 ? 'am-badge-danger' : '' ?>">
                                                        <?= $order['pay_status']['text'] ?></span>
                                                </p>
                                                <p>接单状态：
                                                    <span class="am-badge
                                                <?= $order['shop_status']['value'] > 10 ? 'am-badge-success' : '' ?>">
                                                        <?= $order['shop_status']['text'] ?></span>
                                                </p>
                                                <p>配送状态：
                                                    <span class="am-badge
                                                <?= $order['delivery_status']['value'] == 20 ? 'am-badge-warning' : '' ?>
                                                <?= $order['delivery_status']['value'] == 30 ? 'am-badge-success' : '' ?>">
                                                        <?= $order['delivery_status']['text'] ?></span>
                                                </p>
                                                <p>收货状态：
                                                    <span class="am-badge
                                                <?= $order['receipt_status']['value'] == 20 ? 'am-badge-success' : '' ?>">
                                                        <?= $order['receipt_status']['text'] ?></span>
                                                </p>
												<p>订单状态：
                                                    <span class="am-badge
                                                <?= $order['order_status']['value'] == 10 ? 'am-badge-warning' : '' ?>
												<?= $order['order_status']['value'] == 20 ? 'am-badge-danger' : '' ?>
												<?= $order['order_status']['value'] == 30 ? 'am-badge-success' : '' ?>
												<?= $order['order_status']['value'] == 40 ? 'am-badge-danger' : '' ?>">
												<?= $order['order_status']['value'] == 40 ? $order['refund_status']['text'] : $order['order_status']['text'] ?>
													</span>
                                                </p>
                                            </td>
                                            <td class="am-text-middle" rowspan="<?= $goodsCount ?>">
                                                <div class="tpl-table-black-operation">
                                                    <a class="tpl-table-black-operation-green"
                                                       href="<?= url('order/detail', ['order_id' => $order['order_id']]) ?>">
                                                        订单详情</a>
                                                    <?php if ($order['pay_status']['value'] > 10 AND $order['shop_status']['value'] == 10 AND $order['order_status']['value'] == 10): ?>
                                                        <a class="tpl-table-black-operation"
                                                           href="<?= url('order/detail#shop',
                                                               ['order_id' => $order['order_id']]) ?>">
                                                            确认接单</a>
                                                    <?php endif; ?>
                                                    <?php if ($order['shop_status']['value'] == 20 AND $order['delivery_status']['value'] == 10 AND $order['order_status']['value'] == 10): ?>
                                                        <a class="tpl-table-black-operation"
                                                           href="<?= url('order/detail#delivery',
                                                               ['order_id' => $order['order_id']]) ?>">
                                                            <?= $order['order_mode']['value']==20?'外卖推送':'确认发货'?></a>
                                                    <?php endif; ?>
                                                    <?php if ($order['order_mode']['value'] == 20 AND $order['delivery_status']['value'] == 20 AND $order['delivery']['delivery_status']['value'] == 10 AND $order['order_status']['value'] == 10): ?>
                                                        <a class="tpl-table-black-operation"
                                                           href="<?= url('order/detail#dev20',
                                                               ['order_id' => $order['order_id']]) ?>">
                                                            指派骑手</a>
                                                    <?php endif; ?>
                                                    <?php if ($order['order_mode']['value'] == 20 AND $order['delivery_status']['value'] == 20 AND $order['delivery']['delivery_status']['value'] == 20 AND $order['order_status']['value'] == 10): ?>
                                                        <a class="tpl-table-black-operation"
                                                           href="<?= url('order/detail#dev30',
                                                               ['order_id' => $order['order_id']]) ?>">
                                                            骑手到店</a>
                                                    <?php endif; ?>
                                                    <?php if ($order['order_mode']['value'] == 20 AND $order['delivery_status']['value'] == 20 AND $order['delivery']['delivery_status']['value'] == 30 AND $order['order_status']['value'] == 10): ?>
                                                        <a class="tpl-table-black-operation"
                                                           href="<?= url('order/detail#dev40',
                                                               ['order_id' => $order['order_id']]) ?>">
                                                            外卖配送</a>
                                                    <?php endif; ?>
                                                    <?php if ($order['order_mode']['value'] == 20 AND $order['delivery_status']['value'] == 20 AND $order['delivery']['delivery_status']['value'] == 40  AND $order['order_status']['value'] == 10): ?>
                                                        <a class="tpl-table-black-operation"
                                                           href="<?= url('order/detail#dev50',
                                                               ['order_id' => $order['order_id']]) ?>">
                                                            外卖送达</a>
                                                    <?php endif; ?>
                                                    <?php if ($order['pay_status']['value'] == 30 AND $order['delivery_status']['value'] == 30 AND $order['order_status']['value'] == 10): ?>
                                                        <a class="tpl-table-black-operation"
                                                           href="<?= url('order/detail#collection',
                                                               ['order_id' => $order['order_id']]) ?>">
                                                            确认收款</a>
                                                    <?php endif; ?>
                                                    <?php if ($order['refund_status']['value'] == 10 AND $order['order_status']['value'] == 40): ?>
                                                        <a class="tpl-table-black-operation-del"
                                                           href="<?= url('order/detail#refund',
                                                               ['order_id' => $order['order_id']]) ?>">
                                                            确认退款</a>
                                                    <?php endif; ?>
                                                </div>
                                            </td>
                                        <?php endif; ?>
                                    </tr>
                                <?php endforeach; ?>
                            <?php endforeach; else: ?>
                                <tr>
                                    <td colspan="6" class="am-text-center">暂无记录</td>
                                </tr>
                            <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">
                        <div class="am-fr"><?= $list->render() ?> </div>
                        <div class="am-fr pagination-total am-margin-right">
                            <div class="am-vertical-align-middle">总记录：<?= $list->total() ?></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

